/**
 * 
 */
package com.seraph.zys.web.main;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.seraph.bi.suite.support.security.BaseUser;
import com.seraph.bi.suite.support.security.LoginUtil;
import com.seraph.bi.suite.support.web.json.JsonProviderController;
import com.seraph.zys.dao.ScOrgDAO;
import com.seraph.zys.dao.domain.ScOrg;

/**
 * @author xxx
 *
 */
@Controller
@RequestMapping("/baseLoginInfoController.do")
public class BaseLoginInfoController extends JsonProviderController {

	@Autowired
	private ScOrgDAO scOrgDAO;

	public void setScOrgDAO(ScOrgDAO scOrgDAO) {
		this.scOrgDAO = scOrgDAO;
	}	
	
	@Override
	protected Object handleJsonRequest(HttpServletRequest request,
			HttpServletResponse response) {
		BaseUser user = (BaseUser) LoginUtil.getUser();
		ScOrg scOrg = scOrgDAO.selectByOrgCode(user.getOrgCode());
		Map<String, String> loginInfo = new HashMap<String, String>();
		loginInfo.put("userName", user.getUserAlias());
		loginInfo.put("userCode", user.getUsername());
		loginInfo.put("orgCode", user.getOrgCode());
		loginInfo.put("orgName", scOrg.getOrgName());
		loginInfo.put("orgLevel", scOrg.getOrgLevel().toString());
		return loginInfo;
	}

}
